package DataStructure.二叉树;

import java.util.ArrayList;
import java.util.List;

/**
 * @author ligaojian
 * @version 1.0
 * @description: 中序遍历
 * @date 2021/11/8 22:41
 */
public class inorderTraversal {

    public List<Integer> inorderTraversal1(TreeNode root) {
        List<Integer> arr = new ArrayList<>();
        inorder(root,arr);
        return arr;
    }

    public void inorder(TreeNode root,List<Integer> arr) {

        if (root ==null) {
            return;
        }
         inorder(root.left,arr);
        arr.add(root.val);
        inorder(root.right,arr);
    }
}
